<template>
  <el-dialog
     width="100%"
    :title="''"
    top="0"
    :fullscreen="true"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm"  id="printMe"  v-loading="dataListLoading" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
      	<div class="container-fluid user-manage" id="printarea" style="margin-top:0px;">
		<label style="font-size: 18px; margin-left: 0px;font-weight:bold;">SPCS银政通不动产业务系统 : 抵押不动产查询信息</label>
		<label style="float: right; right: 0px;">{{this.dataForm.printlable}}</label>
				<table width="100%" class="table table-bordered" style="border-collapse: collapse;">
					<tbody>
					<tr>
						<td style="border: solid 1px black;"><b>业务件号：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.serviceno}}</td>
						<td style="border: solid 1px black;"><b>不动产登记证明号：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.realtyno}}</td>
					</tr>
					<tr>
						<td style="border: solid 1px black;"><b>抵押权人名称：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.dyqrname}}</td>
						<td style="border: solid 1px black;"><b>主债权担保金额：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.bdbzqse}} 万元</td>
					</tr>
					<tr>
						<td style="border: solid 1px black;"><b>抵押人在本区域和本接入机构范围内存在多笔抵押：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.isczdbdy}}</td>
						<td style="border: solid 1px black;"><b>抵押方式：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.dyfs}}</td>
					</tr>
					<tr>
						<td style="border: solid 1px black;"><b>债务履行开始日期：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.zwlxqssj}}</td>
						<td style="border: solid 1px black;"><b>债务履行结束日期：</b></td>
						<td style="border: solid 1px black;">{{this.dataForm.zwlxjssj}}</td>
					</tr>
					
					<tr>
            <td style="border: solid 1px black;"><b>被担保债权数额：</b></td>
						<td style="border: solid 1px black;" >{{this.dataForm.bdbzqse}}</td>
						<td style="border: solid 1px black;"><b>债务人：</b></td>
						<td style="border: solid 1px black;" >{{this.dataForm.zwr}}</td>

					</tr>
          <tr>

						<td style="border: solid 1px black;"><b>担保范围：</b></td>
						<td style="border: solid 1px black;" colspan="3" >{{this.dataForm.dbfw}}</td>

					</tr>
					</tbody>
				</table>


    

        <el-row>
          <el-col :span="24">
          <li v-for="(house,index) in this.dataForm.houseList" :key="index" style="width:100%;">
            不动产 - {{index+1}}
 
						<table width="100%" class="table table-bordered" border="1px" cellpadding="0" cellspacing="0" >
              <tbody>
							<tr>
								<td><b>不动产单元号：</b> {{house.realtyunitno}}</td>
								<td><b>不动产权证号：</b> {{house.realtycertno}}</td>
							</tr>

							<tr>
								<td><b>不动产坐落： </b> {{house.zl}}</td>
                <td><b>面积： </b> {{house.mj}}</td>
							</tr>

							<tr>
								<td><b>面积单位： </b> {{house.mjdw}}</td>
                <td><b>是否存在其他行抵押： </b> {{house.isqthdy}}</td>
							</tr>

              <tr>
								<td><b>抵押顺位位次： </b> {{house.dyswwc}}</td>
                <td><b>是否存在查封： </b> {{house.iscf}}</td>
							</tr>

                            <tr>
								<td><b>是否存在在办： </b> {{house.iszb}}</td>
                <td><b>是否存在居住权： </b> {{house.isjzq}}</td>
							</tr>

              </tbody>
						</table>

           
          </li>

          </el-col>
        </el-row>

						<hr style=" height:2px;border:none;border-top:2px dotted #185598;display:none;"/>


            <table id="table-detail" class="table table-bordered"  border="1"  style="border-color:#ddd;"  cellspacing="0">
              <tr>
            		<td class="title" >抵押人名称</td>
            		<td class="title" >抵押人类型</td>
            		<td class="title" >抵押人证件类别</td>
                <td class="title" >抵押人证件号码</td>
            	</tr>
     
                <tr v-for="(dyr,index) in this.dyrList" :key="index">
                  <td  class="text">{{dyr.MC}}</td>
                  <td  class="text" >{{dyr.rylxname}}</td>
                  <td  class="text" >{{dyr.zjlbname}}</td>
                  <td  class="text" >{{dyr.ZJHM}}</td>
                </tr>    
            </table>

    

        </div>

    </el-form>
    <span slot="footer" class="dialog-footer">
       <div id="loading" v-show="printLoading"></div>
      <el-button type="primary" v-print="printObj">打印</el-button>
      <el-button @click="visible = false">关闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {

printLoading: true,
            printObj: {
              id: "printMe",
              popTitle: '不动产信息业务',
              beforeOpenCallback (vue) {
                vue.printLoading = true
                console.log('打开之前')
              },
              openCallback (vue) {
                vue.printLoading = false
                console.log('执行了打印')
              },
              closeCallback (vue) {
                console.log('关闭了打印工具')
              }
            },

        visible: false,
        dataListLoading: false,
        dyrList: [],
        dataForm: {
          serialno: 0,

          qrytime: '',

          region: '',
          serviceno: '',
          realtyno: '',
          realtyunitno: '',
          realtycertno: '',
          dyqrzjlb: '',
          dyqrzjhm: '',

          bdbzqse: '',
          printlable: '',
          dbfw: '',
          houseList: [],
          zwr: ''
        }

      }
    },
    methods: {
      init (id) {
        this.dataForm.serialno = id || 0
        this.visible = true

        this.dataListLoading = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.serialno) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcrealtyinfo/info/${this.dataForm.serialno}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.seqno = data.bdcRealtyinfo.seqno
                this.dataForm.id = data.bdcRealtyinfo.id
                this.dataForm.qrytime = data.bdcRealtyinfo.qrytime
                this.dataForm.obankid = data.bdcRealtyinfo.obankid
                this.dataForm.region = data.bdcRealtyinfo.region
                this.dataForm.serviceno = data.bdcRealtyinfo.serviceno
                this.dataForm.realtyno = data.bdcRealtyinfo.realtyno
                this.dataForm.realtyunitno = data.bdcRealtyinfo.realtyunitno
                this.dataForm.realtycertno = data.bdcRealtyinfo.realtycertno
                this.dataForm.zl = data.bdcRealtyinfo.zl
                this.dataForm.mj = data.bdcRealtyinfo.mj
                this.dataForm.mjdw = data.bdcRealtyinfo.mjdw
                this.dataForm.isqthdy = data.bdcRealtyinfo.isqthdy
                this.dataForm.dyswwc = data.bdcRealtyinfo.dyswwc
                this.dataForm.iscf = data.bdcRealtyinfo.iscf
                this.dataForm.iszb = data.bdcRealtyinfo.iszb
                this.dataForm.isjzq = data.bdcRealtyinfo.isjzq
                this.dataForm.dyfs = data.bdcRealtyinfo.dyfs
                this.dataForm.isdygh = data.bdcRealtyinfo.isdygh
                this.dataForm.dyqrname = data.bdcRealtyinfo.dyqrname
                this.dataForm.dyqrzjlb = data.bdcRealtyinfo.dyqrzjlb
                this.dataForm.dyqrzjhm = data.bdcRealtyinfo.dyqrzjhm
                this.dataForm.iszwrset = data.bdcRealtyinfo.iszwrset
                this.dataForm.isdyrset = data.bdcRealtyinfo.isdyrset
                this.dataForm.isczdbdy = data.bdcRealtyinfo.isczdbdy
                this.dataForm.bdbzqse = data.bdcRealtyinfo.bdbzqse
                this.dataForm.zwlxqssj = data.bdcRealtyinfo.zwlxqssj
                this.dataForm.zwlxjssj = data.bdcRealtyinfo.zwlxjssj
                this.dataForm.dbfw = data.bdcRealtyinfo.dbfw
                this.dataForm.remark = data.bdcRealtyinfo.remark
                this.dataForm.zwr = data.zwr
                this.dyrList = data.dyrList
                this.dataForm.printlable = data.printlable
                this.dataForm.houseList = data.houseList
              }
              this.dataListLoading = false
            })
          }
        })
      },
            selectionChangeHandle (val) {
        this.dataListSelections = val
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/bdc/bdcrealtyinfo/${!this.dataForm.serialno ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'serialno': this.dataForm.serialno || undefined,
                'seqno': this.dataForm.seqno,
                'id': this.dataForm.id,
                'qrytime': this.dataForm.qrytime,
                'obankid': this.dataForm.obankid,
                'region': this.dataForm.region,
                'serviceno': this.dataForm.serviceno,
                'realtyno': this.dataForm.realtyno,
                'realtyunitno': this.dataForm.realtyunitno,
                'realtycertno': this.dataForm.realtycertno,
                'zl': this.dataForm.zl,
                'mj': this.dataForm.mj,
                'mjdw': this.dataForm.mjdw,
                'isqthdy': this.dataForm.isqthdy,
                'dyswwc': this.dataForm.dyswwc,
                'iscf': this.dataForm.iscf,
                'iszb': this.dataForm.iszb,
                'isjzq': this.dataForm.isjzq,
                'dyfs': this.dataForm.dyfs,
                'isdygh': this.dataForm.isdygh,
                'dyqrname': this.dataForm.dyqrname,
                'dyqrzjlb': this.dataForm.dyqrzjlb,
                'dyqrzjhm': this.dataForm.dyqrzjhm,
                'iszwrset': this.dataForm.iszwrset,
                'isdyrset': this.dataForm.isdyrset,
                'isczdbdy': this.dataForm.isczdbdy,
                'bdbzqse': this.dataForm.bdbzqse,
                'zwlxqssj': this.dataForm.zwlxqssj,
                'zwlxjssj': this.dataForm.zwlxjssj,
                'dbfw': this.dataForm.dbfw,
                'remark': this.dataForm.remark
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
<style>
.table-bordered {
    border: 1px solid #ddd;
}
.table {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
}
.table-bordered {
    border: 1px solid #ddd;
}

.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th {
    padding: 8px;
    line-height: 1.42857143;
    color: #81848b;
    vertical-align: top;
    border-top: 1px solid #ddd;

        font-size: 14px;
    font-family: Arial, 'Microsoft YaHei', 'SimSun';
}

.title{
  text-align:center;font-weight:bold; border: 1px solid #ddd;
}

.text{
  text-align:center;font-weight:normal;
  border: 1px solid #ddd;

}

.head{
  text-align:center;font-weight:bold;font-size:16px;background:#D3D3D3;border: 1px solid #ddd;

}
    



.table {
    width: 100%;
    max-width: 100%;
}
</style>